package gmusic.bo;

import gmusic.services.impl.GMusicServicesImpl;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ReleaseBean implements Serializable {

	protected int id;

	protected long maid;

	protected String nom;

	protected int artistId;

	private long artistMaId;

	public static final String anneeColumnName = "annee";
	protected int annee = 0;

	protected int idStyle = -1;

	protected int idLabel = -1;

	protected String commentaire = null;

	protected int typeId;

	//protected String URLCover;

	protected List<TrackBean> tracks = new ArrayList<TrackBean>();

	protected Date creationDate = null;
	
	public static final String reviewColumnName = "review";
	protected String review = null;

	public ReleaseBean() {
	}

	public ReleaseBean(ResultSet rs) throws SQLException {

		setId(rs.getInt("al_id"));
		setNom(rs.getString("al_nom"));
		setArtistId(rs.getInt("al_gr_id"));
		setMaid(rs.getLong("maid"));
		setAnnee(rs.getInt("al_annee"));
		setIdStyle(rs.getInt("al_st_id"));
		setIdLabel(rs.getInt("al_la_id"));
		setCommentaire(rs.getString("al_commentaire"));
		setTypeId(rs.getInt("al_ty_id"));
		setCreationDate(rs.getDate("creation_date"));
		setReview(rs.getString(reviewColumnName));
	}

	public int getId() {
		return id;
	}

	public void setId(int i) {
		id = i;
	}

	public int getGmid() {
		return id;
	}

	public void setGmid(int i) {
		id = i;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String n) {
		nom = n;
	}

	/** @deprecated */
	public int getIdGroupe() {
		return artistId;
	}

	/** @deprecated */
	public void setIdGroupe(int g) {
		artistId = g;
	}

	public int getArtistId() {
		return artistId;
	}

	public int getArtistGmid() {
		return artistId;
	}

	public void setArtistId(int g) {
		artistId = g;
	}

	public int getAnnee() {
		return annee;
	}

	public void setAnnee(int a) {
		annee = a;
	}

	public int getIdStyle() {
		return idStyle;
	}

	public void setIdStyle(int s) {
		idStyle = s;
	}

	public int getIdLabel() {
		return idLabel;
	}

	public void setIdLabel(int l) {
		idLabel = l;
	}

	public String getCommentaire() {
		return commentaire;
	}

	public void setCommentaire(String c) {
		commentaire = c;
	}

	/** @deprecated */
	public int getIdType() {
		return typeId;
	}

	/** @deprecated */
	public void setIdType(int t) {
		typeId = t;
	}

	public int getTypeId() {
		return typeId;
	}

	public void setTypeId(int t) {
		typeId = t;
	}

	public List<TrackBean> getTracks() {
		return tracks;
	}

	public void setTracks(List<TrackBean> tracks) {
		this.tracks = tracks;
	}

	public String toString() {
		return "[gmid=" + id + ";maid=" + maid + ";nom=" + nom + ";annee="
				+ annee + ";type=" + typeId + "]";
	}

	public String getInfo4Console() throws Exception {
		return "###### RELEASE INFO ######\ngmid   " + id + "\nmaid   " + maid
				+ "\nnom    " + nom + "\nannee  " + annee + "\ntype   "
				+ GMusicServicesImpl.getInstance().getType(typeId).getNom()
				+ " (" + typeId + ")\ncover  "
				+ GMusicServicesImpl.getInstance().getCoverFromLocal(this);
	}

	public String toString4Console() {
		return id + "\t" + annee + " " + nom;
	}

	public long getArtistMaId() {
		return artistMaId;
	}

	public void setArtistMaId(long artistMaId) {
		this.artistMaId = artistMaId;
	}

	public long getMaid() {
		return maid;
	}

	public void setMaid(long maid) {
		this.maid = maid;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getCreationDateForDisplay() {
		return creationDate.toString();
	}

	public String getReview() {
		return review;
	}

	public void setReview(String review) {
		this.review = review;
	}
}